package edu.ptu.shortlink.admin.config;

import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @BelongsProject: shortlink
 * @BelongsPackage: edu.ptu.shortlink.admin.config
 * @Author: HYJ
 * @CreateTime: 2025-04-23  22:20
 * @Description: 布隆过滤器配置类
 * @Version: 1.0
 */
@Configuration
public class RBloomFilterConfiguration {
    /**
     * 使用用户布隆过滤器 防止用户注册缓存穿透
     */
    @Bean
    public RBloomFilter<String> userRegisterCachePenetrationBloomFilter(RedissonClient redissonClient) {
        RBloomFilter<String> cachePenetrationBloomFilter = redissonClient.getBloomFilter("userRegisterCachePenetrationBloomFilter");
        cachePenetrationBloomFilter.tryInit(100000000L, 0.001);
        return cachePenetrationBloomFilter;
    }

}
